/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.web.dto.response.user;

import com.monkey.core.domain.user.User;
import com.monkey.core.domain.user.UserStatus;
import com.monkey.core.domain.user.UserStatusHistory;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Wu Tianqiang
 */
public class UserStatusHistoryJSONDto {

    private Long id;

    private Long userId;
    private String account;
    private String nick;

    private UserStatus status;

    private Long opUserId;
    private String opAccount;
    private String opNick;

    private Date opDate;

    private String reason;

    public UserStatusHistoryJSONDto(UserStatusHistory userStatusHistory) {
        this.id = userStatusHistory.getId();
        User user = userStatusHistory.getUser();
        this.userId = user.getId();
        this.account = user.getAccount();
        this.nick = user.getNick();

        this.status = user.getStatus();

        User opUser = userStatusHistory.getOpUser();
        this.opUserId = opUser.getId();
        this.opAccount = opUser.getAccount();
        this.opNick = opUser.getNick();

        this.opDate = userStatusHistory.getOpDate();
        this.reason = userStatusHistory.getReason();
    }


    public static List<UserStatusHistoryJSONDto> toJSONDto(Page<UserStatusHistory> userStatusHistories) {
        List<UserStatusHistoryJSONDto> userStatusHistoryJSONDtos = new ArrayList<>();
        for (UserStatusHistory userStatusHistory : userStatusHistories) {
            userStatusHistoryJSONDtos.add(new UserStatusHistoryJSONDto(userStatusHistory));
        }
        return userStatusHistoryJSONDtos;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getNick() {
        return nick;
    }

    public void setNick(String nick) {
        this.nick = nick;
    }

    public UserStatus getStatus() {
        return status;
    }

    public void setStatus(UserStatus status) {
        this.status = status;
    }

    public Long getOpUserId() {
        return opUserId;
    }

    public void setOpUserId(Long opUserId) {
        this.opUserId = opUserId;
    }

    public String getOpAccount() {
        return opAccount;
    }

    public void setOpAccount(String opAccount) {
        this.opAccount = opAccount;
    }

    public String getOpNick() {
        return opNick;
    }

    public void setOpNick(String opNick) {
        this.opNick = opNick;
    }

    public Date getOpDate() {
        return opDate;
    }

    public void setOpDate(Date opDate) {
        this.opDate = opDate;
    }

    public String getReason() {
        return reason;
    }

    public void setReason(String reason) {
        this.reason = reason;
    }

}